package com.eshin.configuration.scope;

import com.eshin.autotest.bean.OrderBean;
import com.eshin.autotest.bean.RefundBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.scheduling.annotation.Async;

import javax.annotation.PostConstruct;

/**
 * @author Eshin
 * @title: HelloConfiguration
 * @projectName pay
 * @date 2019/5/2816:59
 */


/**
 * 单独扫描此处debug@Scope用，debug其他不要扫描此处
 */
@Configuration
public class HelloConfigurationScope {

    @PostConstruct
    @Async
    public void init(){
        System.out.println("HelloConfigurationScope init...");
    }

    @Bean
    @Scope(value = "singleton",proxyMode = ScopedProxyMode.TARGET_CLASS)
    public OrderBean orderBeanScope(){
        System.out.println("create default orderBeanScope in HelloConfigurationScope");
        return new OrderBean();
    }
    @Bean
    @Scope(value = "thread",proxyMode = ScopedProxyMode.TARGET_CLASS)
    public RefundBean refundBeanScope(){
        System.out.println("create default refundBeanScope in HelloConfigurationScope");
        return new RefundBean();
    }



}
